home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / apidev / batuti.arc / SETUSER.C < prev    next >
Text File  |  1990-01-11  |  2KB  |  65 lines

  1. /*
  2.  *
  3.  *   setuser -- sets the environment variable name in arg[1] to the actual
  4.  *   login user name on ANW 2.1x
  5.  *   Richard Connelly,(C) 1989,1990
  6.  *
  7.  */
  8.  
  9. #include <stdio.h>
  10. #include <conio.h>
  11. #include <dos.h>
  12. #include <mem.h>
  13. #include <process.h>
  14. #include <string.h>
  15. #include "anw.h"
  16. #include "mst_env.h"
  17.  
  18.  
  19.  
  20. void main(int argc, char *argv[])
  21. {
  22.    int station;                     /* station */
  23.    CONNECTINFO who;          /* connection information record */
  24.  
  25. /*
  26.  *  Determine if the user is using the command correctly
  27.  */
  28.  
  29.    if (argc == 1)
  30.    {
  31.       fprintf(stderr," usage:\n\t  setuser env-name  \n");
  32.       exit(-1);
  33.     }
  34.  
  35. /*
  36.  *
  37.  *     get connection information from anw
  38.  *
  39.  */
  40.  
  41.    station=GetConnectionNumber();
  42.    who=GetConnectInfo(station);
  43.    if (strlen(who.objectname))          /* there must be a login name    */
  44.    {                                    /* if the user is logged in      */
  45.                         /* set the environment var passed */
  46.       if (m_putenv(argv[1],who.objectname))
  47.       {
  48.      fprintf(stderr,"Out of environment space\n");
  49.       }
  50.       exit(0);                          /* by argv & terminate successfully*/
  51.    }
  52.    else                                 /* the user did not login */
  53.    {
  54.       fprintf(stderr,"Setuser v1.0\n");
  55.       fprintf(stderr,"\n\n\tYou have not logged into an Advanced Netware Server.\n");
  56.       fprintf(stderr,"\tLogin to the server an execute the command again or \n");
  57.       fprintf(stderr,"\tcontact the network system administrator for assistance. \n\n");
  58.       fprintf(stderr,"\t<< Press Any Key to Continue >>");
  59.       getch();
  60.       fprintf(stderr,"\n");
  61.       exit(-1);                         /* terminate with a failure code */
  62.    }
  63.  
  64. }
  65.